package com.ferapps.tecsa;

import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.view.Menu;
import android.widget.Button;

public class PrefsActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_pref);

	int[] btnArray={R.id.button1, R.id.button2, R.id.button3, R.id.button4, R.id.button5, R.id.button6,
	    R.id.button7, R.id.button8, R.id.button9, R.id.button10 };

	DatabaseHelper databaseHelper=new DatabaseHelper(this);

	databaseHelper.aggiornaPreferitiTUTTI();

	Cursor c=databaseHelper.getPreferiti();
	try {
	    int i=0;
	    while (c.moveToNext()) {
		// Log.d("devAPP", c.getLong(0) + " " + c.getString(1) + " " + c.getString(2));
		Button btnComodo=(Button) findViewById(btnArray[i]);
		btnComodo.setText(c.getString(2));
		i++;
	    }
	}
	finally {
	    c.close();
	}

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
	// Inflate the menu; this adds items to the action bar if it is present.
	getMenuInflater().inflate(R.menu.prefs, menu);
	return true;
    }

}
